{% extends "pretixcontrol/admin/base.html" %}
{% load i18n %}
{% load formset_tags %}

{% block video_admin_content %}
<h1 class="page-header">{% trans "Create event" %}</h1>
<form method="post" class="form-horizontal">
    {% csrf_token %}
    <div class="form-body">
        {{ form.as_p }}
    </div>

    <h3>{% trans "Planned usages" %}</h3>
    <div id="formset" data-formset-prefix="{{ formset.prefix }}">
        {{ formset.management_form }}

        <div class="table-responsive">
        <table class="table table-bordered table-condensed video-admin-table">
            <thead>
                <tr>
                    <th>{% trans "Start" %}</th>
                    <th>{% trans "End" %}</th>
                    <th>{% trans "Attendees" %}</th>
                    <th>{% trans "Notes" %}</th>
                    <th>{% trans "Delete" %}</th>
                </tr>
            </thead>
            <tbody data-formset-body>
            {% for form in formset %}
            <tr data-formset-form>
                <td>{{ form.start }}</td>
                <td>{{ form.end }}</td>
                <td>{{ form.attendees }}</td>
                <td>{{ form.notes }}</td>
                <td><label>{{ form.DELETE }} {% trans "Delete" %}</label></td>
            </tr>
            {% endfor %}
            </tbody>
        </table>
        </div>

        <script type="form-template" data-formset-empty-form>
            {% escapescript %}
            <tr data-formset-form>
                <td>{{ formset.empty_form.start }}</td>
                <td>{{ formset.empty_form.end }}</td>
                <td>{{ formset.empty_form.attendees }}</td>
                <td>{{ formset.empty_form.notes }}</td>
                <td><label>{{ formset.empty_form.DELETE }} {% trans "Delete" %}</label></td>
            </tr>
            {% endescapescript %}
        </script>

        <button type="button" data-formset-add class="btn btn-default btn-xs">
            <span class="fa fa-plus"></span> {% trans "Add planning" %}
        </button>

        <script>jQuery(function($) { $('#formset').formset({ animateForms: false, reorderMode: 'dom' }); });</script>
    </div>

    <div class="video-admin-btn-row">
        <button type="submit" class="btn btn-primary">
            {% if copy_from %}
                <span class="fa fa-clone"></span> {% blocktrans with n=copy_from.pk %}Clone "{{ n }}"{% endblocktrans %}
            {% else %}
                <span class="fa fa-save"></span> {% trans "Save" %}
            {% endif %}
        </button>
        <a href="{% url 'eventyay_admin:video_admin:event.list' %}" class="btn btn-default">{% trans "Cancel" %}</a>
    </div>
</form>
{% endblock %}
